<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>生产抽检</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<style type="text/css">
		 .left-label {
		 	width: 100px !important
		 }
	</style>
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
</head>
<body>
<div class="demoTable" style="padding:10px 0 0 15px">
    <div class="layui-inline">
    	<%--<input class="layui-input" name="searchTime" id="searchTime" placeholder="请输入时间检索" style="display: inline; width: 45%">--%>
        <input class="layui-input" name="keyword" id="keyword" placeholder="请输入膜编号" autocomplete="off" style="display: inline; width: 100%">
    </div>
    <button class="layui-btn layui-btn-blue" style="margin: 0 0 0 10px" data-type="reload"><i class="layui-icon layui-icon-search">搜索</i></button>
</div>
<table class="layui-hide" id="tableList" lay-filter="tableList"></table>

<script type="text/html" id="toolbar">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-blue" lay-event="add"><i class="layui-icon layui-icon-add-1">新增</i></button>
	</div>
</script>
 
<script type="text/html" id="rowToolbar">
	<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
              
<script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/layui.all.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>
 
<script type="text/javascript">
	layui.use(['table','layer','upload','form','laydate'], function(){
		var table = layui.table;
		var layer = layui.layer;
		var laydate = layui.laydate;
	    var form = layui.form;
	    
		var $ = layui.jquery, active = {
			reload:function () {
				/*var searchTime = $("#searchTime").val();*/
				var keyword01 = $("#keyword").val();
				/*console.log(searchTime + ',' + keyword)*/
				table.reload('contenttable',{
					method:'get',
					where:{"keyword01":keyword01}
				});
			}
		}
		$('.layui-btn').on('click', function(){
	        var type = $(this).data('type');
	        active[type] ? active[type].call(this) : '';
	    });
		
		table.render({
		    elem: '#tableList'
		    ,url:'${pageContext.request.contextPath }/productInspect/queryProductInspect.do'
		    //,toolbar: '#toolbar'
		    ,title: '生产抽检'
		    ,id :'contenttable'
		    ,limits:[10,20,30]
		    ,cols: [[
		      {type: 'checkbox', fixed: 'left', },
		      {field:'id', title:'ID', sort: true, type:'numbers'},
		      {field:'nextRoundTime', title:'下轮时间'},
		      {field:'kettle', title:'釜编号'},
		      {field:'filmNumber', title:'膜编号'},
		      {field:'boreSize', title:'内径'},
		      {field:'wallThick', title:'壁厚'},
		      {field:'leakSource', title:'漏点'},
		      {field:'filamentsSurface', title:'膜丝表面'},
		      {field:'fluxLMH', title:'通量LMH'},
		      {field:'strength', title:'强度'},
		      {field:'finalJudgement', title:'最终判定'}
		      /* {unresize: true, title:'操作', width: 110, toolbar: '#rowToolbar'} */
		    ]],
		    page: true
		});
	  
		//头工具栏事件
		table.on('toolbar(tableList)', function(obj){
			var checkStatus = table.checkStatus(obj.config.id);
		    switch(obj.event){
                //新增
		    	case 'add':
			    	layer.open({
						type: 1 					//Page层类型
				  		,area: ['40%', '60%'] 		//宽  高
				  		,title: '新增'
				  		,shade: 0.6 				//遮罩透明度
				  		,maxmin: true 				//允许全屏最小化
				  		,anim: 1 					//0-6的动画形式，-1不开启
				  		/* ,content: $("#addDivID") */
				  		,content: '<div id="addDivID">'+
				  			'<form class="layui-form" id="addFormID">'+
								'<table>'+
									'<tr>'+
										'<td><label class="layui-form-label left-label" style="margin-top: 20px">下轮时间</label></td>'+
										/*'<td>'+
											'<div class="layui-input-block" style="width: 150px; margin-left: 0px; margin-top: 20px">'+
							           			'<select class="layui-select" id="deviceNo" name="deviceNo" lay-filter="displayInfo" lay-verify="deviceNo">'+
							                   		'<option value="">请选择</option>'+
							                   	'</select>'+
							                '</div>'+
							            '</td>'+*/
										'<td><input class="layui-input" id="nextRoundTime" name="nextRoundTime" lay-verify="nextRoundTime" style="width:150px; margin-top:20px"></td>'+
										'<td><label class="layui-form-label" style="margin-top: 20px">釜编号</label></td>'+
										'<td><input class="layui-input" id="kettle" name="kettle" lay-verify="kettle" style="width:150px; margin-top:20px"></td>'+
									'</tr>'+
									'<tr style="height:20px"></tr>'+
									'<tr>'+
										'<td>&emsp;&emsp;&emsp;&emsp;膜编号&emsp;</td>'+
										'<td><input class="layui-input" id="filmNumber" name="filmNumber" lay-verify="filmNumber" style="width:150px"></td>'+
										'<td>&emsp;&emsp;&emsp;&emsp;内径&emsp;</td>'+
										'<td><input class="layui-input" id="boreSize" name="boreSize" lay-verify="boreSize" style="width:150px"></td>'+
									'</tr>'+
									'<tr style="height:20px"></tr>'+
									'<tr>'+
										'<td>&emsp;&emsp;&emsp;&emsp;壁厚&emsp;</td>'+
										'<td><input class="layui-input" id="wallThick" name="wallThick" lay-verify="wallThick" style="width:150px"></td>'+
										'<td>&emsp;&emsp;&emsp;&emsp;漏点&emsp;</td>'+
										'<td><input class="layui-input" id="leakSource" name="leakSource" lay-verify="leakSource" style="width:150px"></td>'+
									'</tr>'+
									'<tr style="height:20px"></tr>'+
									'<tr>'+
										'<td>&emsp;&emsp;&emsp;&emsp;膜丝表面&emsp;</td>'+
										'<td><input class="layui-input" id="filamentsSurface" name="filamentsSurface" lay-verify="filamentsSurface" style="width:150px"></td>'+
										'<td>&emsp;&emsp;&emsp;&emsp;通量LMH&emsp;</td>'+
										'<td><input class="layui-input" id="fluxLMH" name="fluxLMH" lay-verify="fluxLMH" style="width:150px"></td>'+
									'</tr>'+
									'<tr style="height:20px"></tr>'+
									'<tr>'+
										'<td>&emsp;&emsp;&emsp;&emsp;强度&emsp;</td>'+
										'<td><input class="layui-input" id="strength" name="strength" lay-verify="strength" style="width:150px"></td>'+
										'<td>&emsp;&emsp;&emsp;&emsp;最终判定&emsp;</td>'+
										'<td><input class="layui-input" id="finalJudgement" name="finalJudgement" lay-verify="finalJudgement" style="width:150px"></td>'+
									'</tr>'+
									'<tr style="height:20px"></tr>'+
									'<tr align="center">'+
										'<td colspan="2"><button class="layui-btn layui-btn-blue" lay-submit lay-filter="addForm" style="margin-left:160px; margin-bottom: 20px">立即提交</button></td>'+
										'<td colspan="2">&emsp;&emsp;&emsp;&emsp;<button type="reset" class="layui-btn layui-btn-primary" style="margin-bottom: 20px">重置</button></td>'+
									'</tr>'+
								'</table>'+
							'</form>'+
						'</div>'
				  		/* ,end: function(){
				  			$("#addDivID").hide();
				  		} */
				  		,success: function(){
				  			//下轮时间
				  			laydate.render({
				  			    elem: '#nextRoundTime',
				  			    type: 'datetime'
				  			  });
				  		}
					});
		      	break;
		    };
		});
	  
	    /**
         * 通用表单提交(AJAX方式)(新增)
         */
	    form.on('submit(addForm)', function (data) {
	    	$.ajax({
				url : '${pageContext.request.contextPath}/productInspect/addProductInspect.do',
                data: $("#addFormID").serialize(),
				cache : false,
				type : "post",
				}).done(
					function(res) {
						if (res > 0) {
                            toastrStyle();
                            toastr.success('添加成功！');
                            setTimeout(function(){
                                location.reload();
                            },1000);
						}
					}
				).fail(
					function(res) {
                        toastrStyle();
                        toastr.error('添加失败！');
                        setTimeout(function(){
							location.reload();
                        },1000);
					}
				)
				return false;
	    });
        /**
         * 新增表单校验
         */
        form.verify({
            //value：表单的值item：表单的DOM对象
            nextRoundTime: function(value, item){
                if(value == ''){
                    return '字段不能为空';
                }
            },
            kettle: function(value, item){
                if(value == ''){
                    return '字段不能为空';
                }
            },
            filmNumber: function(value, item){
                if(value == ''){
                    return '字段不能为空';
                }
            }
        });
	});
	
	toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上

    //提示框样式
    function toastrStyle(){
        toastr.options = {
            "closeButton": false,
            "debug": false,
            "newestOnTop": false,
            "progressBar": false,
            "positionClass": "toast-top-center",
            "preventDuplicates": false,
            "onclick": null,
            "showDuration": "5000",
            "hideDuration": "1000",
            "timeOut&quot": "100000",
            "extendedTimeOut": "0",
            "showEasing": "swing",
            "hideEasing": "linear",
            "showMethod": "fadeIn",
            "hideMethod": "fadeOut"
        };
    }
</script>

</body>
</html>